package routers

import (
	"HTtravelservia/controllers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

func init() {
	var FilterUser = func(c *context.Context) {
		if c.Request.RequestURI == "/login" {
			return
		}
		_, ok := c.Input.Session("uid").(int)
		if !ok {
			c.Redirect(302, "/login")
		}
	}
	beego.InsertFilter("*", beego.BeforeRouter, FilterUser)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/index_v1.html", &controllers.MainController{}, "*:Index_v1")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")


	//Home
	beego.Router("/home/list_html/*", &controllers.HomeController{}, "*:HTHomeList_html")
	beego.Router("/home/list", &controllers.HomeController{}, "*:HTHomeList")
	beego.Router("/home/detail", &controllers.HomeController{}, "*:HTHomeDetail")
	beego.Router("/home/add", &controllers.HomeController{}, "*:HTHomeAdd")
	beego.Router("/home/update", &controllers.HomeController{}, "*:HTHomeUpdate")
	beego.Router("/home/delete", &controllers.HomeController{}, "*:HTHomeDelete")
	beego.Router("/home/picUp", &controllers.HomeController{}, "*:HTHomePicUp")
	
	//Xiangmu
	beego.Router("/xiangmu/list_html/*", &controllers.XiangmuController{}, "*:HTXiangmuList_html")
	beego.Router("/xiangmu/list", &controllers.XiangmuController{}, "*:HTXiangmuList")
	beego.Router("/xiangmu/detail", &controllers.XiangmuController{}, "*:HTXiangmuDetail")
	beego.Router("/xiangmu/add", &controllers.XiangmuController{}, "*:HTXiangmuAdd")
	beego.Router("/xiangmu/update", &controllers.XiangmuController{}, "*:HTXiangmuUpdate")
	beego.Router("/xiangmu/delete", &controllers.XiangmuController{}, "*:HTXiangmuDelete")
	beego.Router("/xiangmu/changestatus", &controllers.XiangmuController{}, "*:HTXiangmuStatusChange")
	beego.Router("/xiangmu/picUp", &controllers.XiangmuController{}, "*:HTXiangmuPicUp")
	
	//Youji
	beego.Router("/youji/list_html/*", &controllers.YoujiController{}, "*:HTYoujiList_html")
	beego.Router("/youji/list", &controllers.YoujiController{}, "*:HTYoujiList")
	beego.Router("/youji/detail", &controllers.YoujiController{}, "*:HTYoujiDetail")
	beego.Router("/youji/add", &controllers.YoujiController{}, "*:HTYoujiAdd")
	beego.Router("/youji/update", &controllers.YoujiController{}, "*:HTYoujiUpdate")
	beego.Router("/youji/delete", &controllers.YoujiController{}, "*:HTYoujiDelete")
	beego.Router("/youji/changestatus", &controllers.YoujiController{}, "*:HTYoujiStatusChange")
	beego.Router("/youji/multitextimageUp", &controllers.YoujiController{}, "*:HTYoujiMutiTextImageUp")
	beego.Router("/youji/picUp", &controllers.YoujiController{}, "*:HTYoujiPicUp")
	
	//Zixun
	beego.Router("/zixun/list_html/*", &controllers.ZixunController{}, "*:HTZixunList_html")
	beego.Router("/zixun/list", &controllers.ZixunController{}, "*:HTZixunList")
	beego.Router("/zixun/detail", &controllers.ZixunController{}, "*:HTZixunDetail")
	beego.Router("/zixun/add", &controllers.ZixunController{}, "*:HTZixunAdd")
	beego.Router("/zixun/update", &controllers.ZixunController{}, "*:HTZixunUpdate")
	beego.Router("/zixun/delete", &controllers.ZixunController{}, "*:HTZixunDelete")
	beego.Router("/zixun/changestatus", &controllers.ZixunController{}, "*:HTZixunStatusChange")
	beego.Router("/zixun/multitextimageUp", &controllers.ZixunController{}, "*:HTZixunMutiTextImageUp")
	beego.Router("/zixun/picUp", &controllers.ZixunController{}, "*:HTZixunPicUp")
	

}
